﻿@model List<CMP.ERP.Model.Caigouxiangqing>
@{
    Layout = null;
}
@Html.Action("Account_Show", "Account");
    <div class="content">
        <div class="right" id="mainFrame">
            <div class="right_cont">
                <div class="header">


                    <div class="header-right">



        </div>
                </div>
                @*<script>
                        function Cus_Add()
                        {
                            $.ajax({
                                Type: "post",
                                Url: "/Custom_Info/Custom_Info_Add",
                                data: {
                                    Name: $("input['name=Custom_Info_Name']").val(),
                                    Nick: $("input['name=Custom_Info_Nick']")
                                }
                            })
                        }
                    </script>*@
                <!-- 顶部 -->
                <div id="middle">
        <div class="Switch"></div>
        <script type="text/javascript">
            $(document).ready(function (e) {
                $(".Switch").click(function () {
                    $(".left").toggle();

                });
            });
        </script>

        <div class="right" id="mainFrame">

            <div class="right_cont">
                <ul class="breadcrumb">
                    当前位置：
                    <a href="/Home/Index">首页</a>
                    <span class="divider">/</span>
                    客户管理
                </ul>
                <div class="title_right"><strong>客户管理</strong></div>
                <div style="width:100%; margin:auto">
                    <div>
                        <form action="/Stock/SearchByName" method="get">
                            <table>
                                <tr>
                                    <td>商品名称:</td>
                                    <td><input type="text" name="Commodity_Name" /></td>

                                    <td><button type="submit" class="btn btn-default"><span class="icon-search"></span>查询 </button></td>
                                    
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div style="margin-top:20px;">
                        <table class="table  table-hover table-bordered table-striped" id="por">
                            <thead>
                                <tr>
                                    <th>业务日期</th>
                                    <th>单据编码</th>
                                    <th>商品总额</th>
                                    <th>供应商</th>
                                    <th>仓库</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <br />
                        <table class="table  table-hover table-bordered table-striped">
                            <thead>
                                <tr>
                                    <td><input id="Checkbox1" type="checkbox"  onclick="fcc()"/></td>
                                    <th>商品名称</th>
                                    <th>商品编码</th>
                                    <th>商品重量</th>
                                    <th>商品备注</th>
                                    <th>商品价格</th>
                                    <th>商品类型名称</th>
                                    <th>采购数量</th>
                                </tr>
                            </thead>
                            <tbody>

                                @foreach (var item in Model)
                                {
                                    <tr>
                                        <td><input id="Checkbox1" name="ck" type="checkbox" onclick="fcc1()" value="@item.PorMaid"/></td>
                                        <td>@item.Commodity_Name<input id="Text1" type="hidden" value="@item.pid" /></td>
                                        <td>@item.Commodity_number</td>
                                        <td>@item.Commodity_Weight</td>
                                        <td>@item.Commodity_Remark</td>
                                        <td>@item.Commodity_Price</td>
                                        <td>@item.CommodityType_Name</td>
                                        <td>@item.Por_num</td>
                                    </tr>
                                }

                            </tbody>
                        </table>

                    </div>
                </div>


            </div>
        </div>
    </div>
                <button type="button" class="btn btn-default" onclick="Into()"><span class="icon-search"></span>审核完成并入库</button>
    <!-- 底部 -->
    <div id="footer">版权所有：知行科技</div>


            </div>
        </div>


    </div>
   
    <script>
    $(function () {

        $.ajax({
            type: "get",
            url: "/Procurement/XQ",
            data: {
                id:@Session["id"],
            },
            success: function (data) {
                $(data).each(function (index,item) {
                        
                    var str = "" + item.PorBuy_Date + "";
                    function data_string(str) {
                        var d = eval('new ' + str.substr(1, str.length - 2));
                        var ar_date = [d.getFullYear(), d.getMonth() + 1, d.getDate()];
                        for (var i = 0; i < ar_date.length; i++) ar_date[i] = dFormat(ar_date[i]);
                        return ar_date.join('-');

                        function dFormat(i) { return i < 10 ? "0" + i.toString() : i; }
                    }
                    var ss = "<tr><td>" + data_string(str) + "</td><td>" + item.PorBuy_Cid + "</td><td>" + item.PorBuy_SumMoney + "</td><td>" + item.Supplier_Name + "</td><td id="+item.WareHose_Id+" value="+item.WareHose_Id+">" + item.WareHose_Name + "</td></tr>";
                        $("#por tbody").append(ss);
                })
            }
        })
    })
        function fcc()
        {
            if($("#Checkbox1").attr("checked")=="checked")
            {
                $(":checkbox").attr("checked","checked");
            }
            else
            {
                $(":checkbox").removeAttr("checked","checked");
            }
        }
        function fcc1()
        {
            if ($("[name='ck']:checked").length == $("[name='ck']").length) {
                $("#Checkbox1").attr("checked", "checked");
            } 
            else
            {
                $("#Checkbox1").removeAttr("checked");
            }
        var selectvalue = "";
        var emplist = $("[name='ck']:checked");
        $(emplist).each(function (index, p) {
            if (selectvalue.length > 0) {
                selectvalue += ",";
            }
            selectvalue += $(p).val();
        })
    }
    function Into()
    {
        var selectvalue = "";
        var emplist = $("[name='ck']:checked");
        $(emplist).each(function (index, p) {
            if (selectvalue.length > 0) {
                selectvalue += ",";
            }
            selectvalue += $(p).val();
        })
     
        $.ajax({
            type:"post",
            url:"/Procurement/update",
            data:{
                pidtr:selectvalue
            },
            success:function(data){
            
                if(data=="True")
                {
                    alert("已入库");
                    location.reload();
                }
                else
                {
                    alert("还差点");
                }
            }
        })
        }
    </script>






